       IDENTIFICATION DIVISION.
       PROGRAM-ID. IndexarArchivoClientes.
       AUTHOR. Grupo 5. 2do cuatrimestre 2011.

       ENVIRONMENT DIVISION.
         INPUT-OUTPUT SECTION.
           FILE-CONTROL.
             SELECT SEQ-ARCH ASSIGN TO "CLIENTES.SEQ"
                 ORGANIZATION IS LINE SEQUENTIAL.

             SELECT CLI-ARCH ASSIGN TO "CLIENTES.IDX"
                 ORGANIZATION IS INDEXED
                 ACCESS MODE IS RANDOM
                 RECORD KEY IS CLI-COD-CLI
                 ALTERNATE RECORD KEY IS CLI-CUIT
                 FILE STATUS IS CLI-STATUS.

       DATA DIVISION.
         FILE SECTION.
           COPY "Clientes-FD.cbl".

           FD SEQ-ARCH.
           01 SEQ-REG.
             88 SEQ-EOF                 VALUE HIGH-VALUES.
             02 SEQ-FIELDS              PIC X(81).

         WORKING-STORAGE SECTION.
           01 CLI-STATUS                PIC X(02).

       PROCEDURE DIVISION.
         OPEN INPUT SEQ-ARCH
         OPEN OUTPUT CLI-ARCH

         READ SEQ-ARCH
             AT END SET SEQ-EOF TO TRUE
         END-READ

         PERFORM UNTIL SEQ-EOF
             MOVE SEQ-REG TO CLI-REG
             WRITE CLI-REG
                 INVALID KEY DISPLAY "CLAVE INVALIDA " CLI-COD-CLI
             END-WRITE

             READ SEQ-ARCH
                 AT END SET SEQ-EOF TO TRUE
             END-READ
         END-PERFORM
          
         CLOSE SEQ-ARCH
         CLOSE CLI-ARCH
          
         STOP RUN
         .
